//
//@File    :	9.4_auto.cpp
//@Time    :	2021/08/22 16:38:36
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	illustrating scope of automatic varibles
//

//存储持续性,作用域,链接性
//自动存储持续性:变量在函数或代码块中
//静态存储持续性:static和函数外定义的变量,整个运行过程都存在
//线程存储持续性:thread_loacl声明的变量存在于整个线程
//动态存储持续性:new分配,delete释放或程序结束为止,被称为自由存储(free store)或堆(heap)

#include <iostream>

using namespace std;
void oil(int x);
int main()
{
    int texas = 31;
    int year = 2011;
    cout << "In main(),texas = " << texas << ", &texas = ";
    cout << &texas << endl;
    cout << "In main(),year = " << year << ", &year = ";
    cout << &year << endl;
    oil(texas);
    cout << "In main(),texas = " << texas << ", &texas = ";
    cout << &texas << endl;
    cout << "In main(),year = " << year << ", &year = ";
    cout << &year << endl;
    system("pause");
    return 0;
}
void oil(int x)
{
    int texas = 5;

    cout << "In oil(),texas = " << texas << ", &texas = ";
    cout << &texas << endl;
    cout << "In oil(),x = " << x << ", &year = ";
    cout << &x << endl;
    {
        int texas = 113;
        cout << "In oil(),texas = " << texas << ", &texas = ";
        cout << &texas << endl;
        cout << "In oil(),x = " << x << ", &year = ";
        cout << &x << endl;
    }
    cout<<"Post-block texas = "<<texas;
    cout<<",&texas = "<<&texas<<endl;
}
